Skip to content

Add Qiskit route/validity/cost-phase construction with Aer table reproduction - #1

Merged
fgfuchs merged 6 commits into
mainfrom
copilot/implement-qiskit-circuit
Sep 3, 2026
Merged

Add Qiskit route/validity/cost-phase construction with Aer table reproduction#1
fgfuchs merged 6 commits into
mainfrom
copilot/implement-qiskit-circuit

Conversation

Copilot AI commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Implements a Qiskit circuit version of the paper’s construction while preserving the existing PennyLane implementation. Adds an Aer statevector example that reproduces the tour table (tour, (\phi), validity) and renders the full table as a plot.

  • Qiskit construction module (src/qiskit_route_construction.py)

    • Introduces explicit register layout for route, validity ancillas, good, and phase ancilla.
    • Implements reversible validity oracle as separate compute/uncompute passes.
    • Implements validity-controlled cost-phase oracle (start edge, internal transitions, return edge).
    • Adds helpers for route decoding, classical validity/cost reference, and phase-table generation.
  • Paper-style Aer example (qiskit_route_construction_example.py)

    • Builds normalized TSP instance (n=5, seed=42 default), runs statevector simulation, and emits full table.
    • Outputs:
      • qiskit_tsp_table.csv
      • qiskit_tsp_table.png (all entries plotted as a table figure).
  • Test coverage (tests/test_qiskit_route_construction.py)

    • Verifies oracle marks only permutation-valid routes.
    • Verifies valid-route relative phase matches classical route cost differences.
    • Verifies ancilla cleanup after uncomputation (no residual probability outside ancilla-zero subspace).
  • Project integration

    • Adds Qiskit/Aer + plotting/test dependencies in requirements.txt.
    • Extends README with concise usage for the new Qiskit flow.
from src.qiskit_route_construction import build_qiskit_tsp_construction_circuit
from qiskit_aer import Aer

circuit, layout = build_qiskit_tsp_construction_circuit(cost_matrix, start_node=4)
state = Aer.get_backend("statevector_simulator").run(circuit).result().get_statevector(circuit)

Copilot AI and others added 2 commits September 2, 2026 08:30
Co-authored-by: fgfuchs <2428162+fgfuchs@users.noreply.github.com>
Co-authored-by: fgfuchs <2428162+fgfuchs@users.noreply.github.com>
Copilot AI and others added 2 commits September 2, 2026 09:09
Co-authored-by: fgfuchs <2428162+fgfuchs@users.noreply.github.com>
Co-authored-by: fgfuchs <2428162+fgfuchs@users.noreply.github.com>
Copilot AI requested a review from fgfuchs September 2, 2026 09:12

@fgfuchs fgfuchs left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

works

@fgfuchs
fgfuchs marked this pull request as ready for review September 3, 2026 10:26
@fgfuchs
fgfuchs merged commit f6d3216 into main Sep 3, 2026
@fgfuchs
fgfuchs deleted the copilot/implement-qiskit-circuit branch September 3, 2026 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants